package com.gismore.jsonp;

import com.gismore.jsonp.config.AppConfig;
import com.gismore.jsonp.core.Collector;
import com.gismore.jsonp.core.Parser;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.util.List;

/**
 * 应用入口
 */
public class Main {
	public static void main(String[] args) throws IOException {
		AppConfig.init();
		Logger log = LogManager.getLogger(Main.class);

		String url = null;
		if(args == null || args.length == 0){
			log.error("缺少参数{url}");
			return;
		}
		url = args[0];
		log.info("url:{}",url);
		List<String> rawLinks = Collector.collect(url);
		Parser parser = new Parser();
		List<String> links =  parser.parse(rawLinks);

		System.out.println();

		links.stream().forEach(System.out::println);

		System.out.println();
	}
}
